<div class="container-fluid my-3">
  <h2>
    {{ get_icon('b_triggers', t('Triggers')) }}
    {{ show_mysql_docu('TRIGGERS') }}
  </h2>

  <div class="d-flex flex-wrap my-3">
    {%- if triggers is not empty %}
    <div>
      <div class="input-group">
        <div class="input-group-text">
          <div class="form-check mb-0">
            <input class="form-check-input checkall_box" type="checkbox" value="" id="checkAllCheckbox" form="rteListForm">
            <label class="form-check-label" for="checkAllCheckbox">{{ t('Check all') }}</label>
          </div>
        </div>
        <button class="btn btn-outline-secondary" id="bulkActionExportButton" type="submit" name="submit_mult" value="export" form="rteListForm" title="{{ t('Export') }}">
          {{ get_icon('b_export', t('Export')) }}
        </button>
        <button class="btn btn-outline-secondary" id="bulkActionDropButton" type="submit" name="submit_mult" value="drop" form="rteListForm" title="{{ t('Drop') }}">
          {{ get_icon('b_drop', t('Drop')) }}
        </button>
      </div>
    </div>
    {%- endif %}

    <div{{ triggers is not empty ? ' class="ms-auto"' }}>
      <a class="ajax add_anchor btn btn-primary{{ not has_privilege ? ' disabled' }}" href="{{ url('/triggers', {'db': db, 'table': table, 'add_item': true}) }}" role="button"{{ not has_privilege ? ' tabindex="-1" aria-disabled="true"' }}>
        {{ get_icon('b_trigger_add', t('Create new trigger')) }}
      </a>
    </div>
  </div>

  {{ error_message|raw -}}

  <form id="rteListForm" class="ajax" action="{{ url('/triggers') }}">
    {{ get_hidden_inputs(db, table) }}

    <div id="nothing2display"{{ triggers is not empty ? ' class="hide"' }}>
      {{ t('There are no triggers to display.')|notice }}
    </div>

    <table id="triggersTable" class="table table-striped table-hover{{ triggers is empty ? ' hide' }} w-auto data">
      <thead>
        <tr>
          <th></th>
          <th>{{ t('Name') }}</th>
          {% if table is empty %}
            <th>{{ t('Table') }}</th>
          {% endif %}
          <th>{{ t('Time') }}</th>
          <th>{{ t('Event') }}</th>
          <th colspan="3"></th>
        </tr>
      </thead>
      <tbody>
        <tr class="hide">{% for i in 0..(table is empty ? 7 : 6) %}<td></td>{% endfor %}</tr>

        {%- for trigger in triggers %}
          {{- include(
            'triggers/row.twig',
            {
              'db': db,
              'table': table,
              'trigger': trigger,
              'has_drop_privilege': has_privilege,
              'has_edit_privilege': has_privilege,
              'row_class': is_ajax ? 'ajaxInsert hide' : '',
            },
            with_context = false
          ) }}
        {%- endfor %}
      </tbody>
    </table>
  </form>
</div>
